💡 Paper Reference & Attribution: This article is derived from an in-depth study, engineering analysis, and architectural interpretation of the Microsoft research paper From Local to Global: A Graph RAG Approach to Query-Focused Summarization (arXiv:2404.16130).
Once the GraphRAG knowledge graph and community hierarchy have been built, the retrieval phase does not rebuild the graph. Instead, it leverages precomputed graph indices, community hierarchies, and summaries to perform:
The retrieval pipeline operates strictly over pre-indexed artifacts without re-extracting entities or re-clustering graphs at query time.
A built GraphRAG instance typically exposes the following structured data entities:
entities: Canonical entity registryentity_aliases: Synonym and alias mappingedges: Weighted relationship links between entitiescommunities: Hierarchical community nodescommunity_members: Entity-to-community membership tablescommunity_summaries: Pre-generated thematic summaries per communityclaims: Factual claims, assertions, and supporting evidence snippetsGraphRAG retrieval operates as a hybrid pipeline combining deterministic algorithmic scoring with LLM-powered semantic augmentation.
MERMAID
Upon receiving a user query, the pipeline extracts key signals:
For example:
textQuery: "What is the historical background of collaboration between Organization A and Company B?"
Extracted signals:
Candidate entities are retrieved across multiple channels:
The multi-channel candidate lists are merged using Reciprocal Rank Fusion (RRF) to produce a unified, confidence-ranked entity set:
Starting from the matched entity set , expand to 1-hop graph neighbors:
Where represents the set of weighted edges. This broadens retrieval from explicit keyword mentions to semantically and structurally relevant contextual entities.
Map the expanded entity pool back into community memberships:
Where is the entity set belonging to community , and represents the candidate community set.
Candidate communities are scored and ranked to select the Top- relevant partitions:
Where:
When combining signals with vastly different scales (e.g. cosine similarity vs integer degree counts), calculate independent rank orders across each signal and fuse them using RRF:
Top candidate communities undergo an LLM verification step:
Top- communities return comprehensive context:
The LLM synthesizes this structured context into a coherent global response.
(Where is the set of ranking channels, is the 1-based rank, and is the smoothing constant).
typescripttype Edge = { sourceEntityId: string; targetEntityId: string; relationType: string; }; type AggregatedEdge = { sourceEntityId: string; targetEntityId: string; relationType: string; weight: number; }; function aggregateEdges(edges: Edge[]): AggregatedEdge[] { const map = new Map<string, AggregatedEdge>(); for (const item of edges) { const key = `${item.sourceEntityId}::${item.targetEntityId}::${item.relationType}`; const existing = map.get(key); if (existing) { existing.weight += 1; } else { map.set(key, { sourceEntityId: item.sourceEntityId, targetEntityId: item.targetEntityId, relationType: item.relationType, weight: 1, }); } } return Array.from(map.values()); } function scoreCommunity( query: string, communitySummary: string, entityNames: string[], similarityFn: (a: string, b: string) => number ): number { const semanticScore = similarityFn(query, communitySummary); const entityScore = entityNames.reduce( (sum, entity) => sum + similarityFn(query, entity), 0 ); return semanticScore + 0.5 * entityScore; } function reciprocalRankFusion<T>( rankedLists: T[][], getId: (item: T) => string, k = 60 ): Array<{ item: T; score: number }> { const scoreMap = new Map<string, { item: T; score: number }>(); for (const list of rankedLists) { list.forEach((item, index) => { const id = getId(item); const rank = index + 1; const current = scoreMap.get(id); const rrfScore = 1 / (k + rank); if (current) { current.score += rrfScore; } else { scoreMap.set(id, { item, score: rrfScore }); } }); } return Array.from(scoreMap.values()).sort((a, b) => b.score - a.score); }
MERMAID